//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.bgs.controller;

import com.bgs.entity.Commodityorder;
import com.bgs.entity.Recyclingorder;
import com.bgs.entity.User;
import com.bgs.service.CommodityService;
import com.bgs.tool.R;
import com.bgs.vo.Dingdanchaxun;
import com.bgs.vo.Kucun;
import com.bgs.vo.Page;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/gwb"})
public class CommodityController {
    @Autowired
    private CommodityService commodityService;

    public CommodityController() {
    }

    @ApiOperation("查询库存管理数据-gwb")
    @GetMapping({"/pageList"})
    public PageInfo<Kucun> pageList(Page page, String commodityNumber, String commodityName, Integer storeId) {
        PageInfo<Kucun> list = this.commodityService.pageList(page, commodityNumber, commodityName, storeId);
        return list;
    }

    @ApiOperation("申请送货-gwb")
    @PostMapping({"/upnum"})
    public R update(@RequestBody Kucun kucun) {
        int a = this.commodityService.songhuo(kucun);
        return a == 1 ? R.ok() : R.error();
    }

    @ApiOperation("查询回收订单管理-gwb")
    @GetMapping({"/pageListhuichou"})
    public PageInfo<Recyclingorder> pageListhuichou(Page page, Dingdanchaxun dingdanchaxun) {
        PageInfo<Recyclingorder> list = this.commodityService.pageListhuichou(page, dingdanchaxun);
        return list;
    }

    @ApiOperation("查询骑手id-gwb")
    @PostMapping({"/qsid"})
    public R qsid(@RequestBody Recyclingorder recyclingorder) {
        User user = this.commodityService.qsid(recyclingorder);
        return R.ok().data("contractResult", user);
    }

    @ApiOperation("查询可用骑手-gwb")
    @GetMapping({"/cxshy"})
    public R cxshy(Integer storeId) {
        System.out.println(storeId);
        List<User> list1 = this.commodityService.lisyqs(storeId);
        return R.ok().data("contractResult", list1);
    }

    @ApiOperation("修改骑手状态绑定信息-gwb")
    @PostMapping({"/xgzt/{userId}/{roId}"})
    public R xgzt(@PathVariable("userId") Integer userId, @PathVariable("roId") Integer roId) {
        this.commodityService.xg(userId, roId);
        return R.ok();
    }

    @ApiOperation("修改订单状态-gwb")
    @GetMapping({"/updatezt"})
    public R updatezt(Integer roId) {
        System.out.println(roId);
        this.commodityService.updatezt(roId);
        return R.ok();
    }

    @ApiOperation("查询兑换订单管理数据-gwb")
    @GetMapping({"/pageListduihuan"})
    public PageInfo<Commodityorder> pageListduihuan(Page page, String number, Integer deliveryMethod, Integer storeId) {
        PageInfo<Commodityorder> list = this.commodityService.pageListduihuan(page, number, deliveryMethod, storeId);
        return list;
    }

    @ApiOperation("取货列表-gwb")
    @GetMapping({"/qhcx"})
    public R qhcx(Integer commodityId) {
        List<Kucun> list = this.commodityService.qhcx(commodityId);
        return R.ok().data("list",list);
    }

    @ApiOperation("取货列表-gwb")
    @GetMapping({"/qupdate"})
    public R qupdate(Integer coId) {
        int i = this.commodityService.qupdate(coId);
        return i == 1 ? R.ok() : R.error();
    }

    @ApiOperation("首页展示订单-gwb")
    @GetMapping({"/list2"})
    public R list2(Integer storeId) {
        List<Recyclingorder> list2 = this.commodityService.list2(storeId);
        return R.ok().data("contractResult", list2);
    }
}
